package hr.chus.alfresco.struts2.action;

import org.alfresco.service.ServiceRegistry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;

/**
 * Configured using convention plugin.
 * 
 * @author Jan Čustović (jan.custovic@gmail.com)
 */
@SuppressWarnings("serial")
@ParentPackage("json-default")
@Namespace("/annotation")
@Action("example")
@Result(type = "json")
public class AnnotationExampleAction extends ActionSupport {

    private static final Log LOG = LogFactory.getLog(AnnotationExampleAction.class);

    @Autowired
    private ServiceRegistry  serviceRegistry;

    private String           msg;

    @Override
    public String execute() throws Exception {
        LOG.info("Received msg: " + msg);
        LOG.info("Autowired ServiceRegistry: " + serviceRegistry);
        return SUCCESS;
    }

    // Getters & setters

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

}
